import http from '@/base/http';

/**
 * 登录
 */
enum API_LOGIN {
  WX_CODE = '/wechat/qetAuthorizationUrl',
  SMS_LOGIN = '/login/smsLogin', // 账号验证码登录
  SMS_SEND = '/api/sms/send', // 发送验证码
  WX_LOGIN = '/login/miniProgramLogin', // 微信登陆
  WX_REGISTER= '/login/register', // 注册
  LOGIN = '/api/v2/WxApp/Login', // 登录
  LOGINOUT = '/login/logout', // 退出登录
  USERE_CANCEL = '/wx/user/cancelAccount', // 退出登录
  AUTH = '/api/v1/WxApp/auth', // 获取用户信息
  OPEN_TOKEN = '/api/Open/GetNewOpenToken', // 获取openToken
  AGREEMENT = '/login/user-agreement', // 用户协议
  PRIVACYPOLICY = '/login/privacy-policy', // 用户协议
  syncLocation = '/api/location/sync-location', // 定位 
}

export function login(data: unknown): Promise<any> {
  return http.post(API_LOGIN.LOGIN, data);
}

export function sendSms(data: unknown): Promise<any> {
  return http.post(API_LOGIN.SMS_SEND, data);
}

export function smsLogin(data: unknown): Promise<any> {
  return http.post(API_LOGIN.SMS_LOGIN, data);
}

export function getWxCode (data: unknown): Promise<any> {
  return http.get(API_LOGIN.WX_CODE, data);
}

export function wxLogin(data: unknown): Promise<any> {
  return http.get(API_LOGIN.WX_LOGIN, data);
}

export function wxLogout(data: unknown): Promise<any> {
  return http.post(API_LOGIN.LOGINOUT, data);
}

export function wxUserCancel(data: unknown): Promise<any> {
  return http.post(API_LOGIN.USERE_CANCEL, data);
}

export function register(data: unknown): Promise<any> {
  return http.post(API_LOGIN.WX_REGISTER, data);
}

export function auth(data: unknown): Promise<any> {
  return http.post(API_LOGIN.AUTH, data);
}

export function GetNewOpenToken(data: unknown): Promise<any> {
  return http.post(API_LOGIN.OPEN_TOKEN, data);
}

export function getUserAgreement(): Promise<any> {
  return http.get(API_LOGIN.AGREEMENT);
}

export function getPrivacyPolicy(): Promise<any> {
  return http.get(API_LOGIN.PRIVACYPOLICY);
}

export function syncLocation(data: unknown): Promise<any> {
  return http.post(API_LOGIN.syncLocation, data);
}
